/* -----------------------------------------------------------------------
 * Becky Kluth
 * CS 362
 * Assignment 3: unittest3.c test of function discardCard() in dominion.c
 *
 * unittest3: unittest3.c dominion.o rngs.o
 *      gcc -o unittest3 -g  unittest3.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

//set NOISY_TEST to 0 to remove printfs from output (this macro take from the example)
#define NOISY_TEST 0

int main() {
	int seed = 1000;										//initiate a two player game
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
    struct gameState G;
	int crash;
	int startingHandCount;
	int startingCardCount;

    initializeGame(numPlayer, k, seed, &G);

    printf ("Testing discardCard():\n");

	startingHandCount = G.handCount[0];	
	startingCardCount = G.playedCardCount;
#if (NOISY_TEST == 1)
	printf("Start hand count: %d, discard count: %d\n", startingHandCount, startingCardCount);
#endif
	crash = discardCard(0, 0, &G, 0);						//discard a card with trash flag off
	assert(crash == 0);							
	assert(G.handCount[0] == startingHandCount - 1);		//1 less card in hand
	assert(G.playedCardCount == startingCardCount + 1);		//1 more card played
#if (NOISY_TEST == 1)
	printf("End hand count: %d, discard count: %d\n", G.handCount[0], G.playedCardCount);
#endif

	startingHandCount = G.handCount[0];	
	startingCardCount = G.playedCardCount;
#if (NOISY_TEST == 1)
	printf("Start hand count: %d, discard count: %d\n", startingHandCount, startingCardCount);
#endif
	crash = discardCard(1, 0, &G, 1);						//discard a card with trash flag on
	assert(crash == 0);							
	assert(G.handCount[0] == startingHandCount - 1);		//1 less card in hand
	assert(G.playedCardCount == startingCardCount);			//no change in card played amount
#if (NOISY_TEST == 1)
	printf("End hand count: %d, discard count: %d\n", G.handCount[0], G.playedCardCount);
#endif

    printf("All tests passed!\n");

    return 0;
}